# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Douglas Soares de Andrade <douglas@archlinux.org>

pkgbase=mtr
pkgname=('mtr' 'mtr-gtk')
pkgver=0.95
pkgrel=4
pkgdesc='Combines the functionality of traceroute and ping into one tool'
url='https://www.bitwizard.nl/mtr/'
arch=('loong64' 'x86_64')
license=('GPL-2.0-only')
makedepends=(
  'gdk-pixbuf2'
  'glibc'
  'gtk3'
  'jansson'
  'libcap'
  'ncurses'
)
install=mtr.install
source=(https://github.com/traviscross/mtr/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('a7d69e0c551a10ae80a650a34588119e6c6b124a8c2c93d3de29e5daa6ef99f9217d875529d443c3760cd6fd7bd04d1e9abe33ef12635826c66a98bd776c1690')
b2sums=('3c972675b97945b96562802c5d0f10de963160682c93c0ea2991b72eca33d136d18948c5e746ca3dfb280ebc9c3ab154e7774f8409ed4e5f7470a8feb128e71b')

prepare() {
  (cd ${pkgbase}-${pkgver}
    echo "${pkgver}" > .tarball-version
    autoreconf -fiv
  )
  cp -ra ${pkgbase}-${pkgver}{,-cli}
}

build() {
  (cd ${pkgbase}-${pkgver}-cli
    ./configure \
      --prefix=/usr \
      --without-gtk \
      --sbindir=/usr/bin
    make
  )
  (cd ${pkgbase}-${pkgver}
    ./configure \
      --prefix=/usr \
      --sbindir=/usr/bin
    make
  )
}

package_mtr() {
  pkgdesc='Combines the functionality of traceroute and ping into one tool (CLI version)'
  depends=(
    'glibc'
    'jansson'
    'libcap'
    'ncurses' libncursesw.so
  )
  optdepends=('bash-completion: bash completion support')
  cd ${pkgbase}-${pkgver}-cli
  make DESTDIR="${pkgdir}" install
}

package_mtr-gtk() {
  pkgdesc='Combines the functionality of traceroute and ping into one tool (GTK version)'
  depends=(
    'gdk-pixbuf2' libgdk_pixbuf-2.0.so
    'glib2' libglib-2.0.so libgobject-2.0.so
    'glibc'
    'gtk3' libgtk-3.so
    'jansson'
    'libcap'
    'ncurses' libncursesw.so
  )
  optdepends=('bash-completion: bash completion support')
  conflicts=('mtr')
  provides=("mtr=${pkgver}")
  cd ${pkgbase}-${pkgver}
  make DESTDIR="${pkgdir}" install
}

# vim: ts=2 sw=2 et:
